//---------------------------------------------------------------------------- // File: Bitmap.h // Type: Bitmap File management. // Author: Ken Anderson // Date: 10/13/3 // OS dependant: N/A // // Notes: Code required to manipulate a bitmap such as load & convert it. // // Required Headers: // 1) Image.h -- Contains all common image definitions & formats that are // shared amongst the several image format. // Also contains access to CalculatePaddedBytes. // IM_ERROR codes are listed in this header file. //---------------------------------------------------------------------------- #ifndef _BITMAP_MX_ #define _BITMAP_MX_ #include "Image.h" //-----------------------Bitmap Structures------------------------------------- //The bitmap file format used here is Microsoft's DIB format. It is the most raw image //data map there is. Each color intensity for each pixel is described in each byte //as opposed to jpegs and pngs which have compression factors. //Bitmap File Info Structure. //This structure contains information about the bitmap's file. #pragma pack(2) //Pack the structure otherwise the bitmap will NOT load correctly. typedef struct tgBITMAP_FILE_INFO { Word Type; //The type of media. Dword Size; //Size of the entire file. Word Reserved0; //Must be zero. Reserved. Word Reserved1; //Must be zero. Reserved. Dword Offbits; //Offset[in bytes] where the actual bitmap data starts after this structure. } BitmapFileInfo, *pBitmapFileInfo, BFI, *PBFI; #pragma pack() //Unpack it so the rest of our structures are not damaged. //Bitmap Image Info Structure. //This structure contains the true information about the bitmap and its structure //such as size, color depth, compression and other important properties. typedef struct tgBITMAP_IMAGE_INFO { Dword Size; //Size of BitmapImageInfo structure. long Width; //Width of the Bitmap. long Height; //Height of the Bitmap. Word Planes; //Number of planes. Word BitCount; //Number of bits per color used. Dword Compression; //Compression of the file. Dword SizeImage; //Full size of the image. long XPelsPerMeter; //Horizontal Resolution. long YPelsPerMeter; //Vertical Resolution. Dword ClrUsed; //Colors used in 8-bit images and below. Dword ClrImportant; //Colors that are important in an 8-bit image and below } BitmapImageInfo, *PBitmapImageInfo, BII, *PBII; //Bitmap //This structure contains the entire bitmap. typedef struct tgFULL_BITMAP_BLOCK { BitmapFileInfo fi; //File information of the bitmap. BitmapImageInfo bi; //Image info of the bitmap. ColorARGB* palette; //Image palette. void* vpBits; //The bitmaps actual bits. //Miscellaneous infomation created through calculation during loadtime. //Removed from the BitmapImageInfo to allow the file to be read correctly. long WidthBytes; //Length of the scanline padded with zeros. } Bitmap, *PBitmap, BM, *PBM; //---------------------------------Bitmap Functions----------------------------------------------// IM_ERROR InitBitmap(PBitmap pBmp); IM_ERROR CreateBitmap(PBitmap* hBmp, IMFORMAT_BD format = IMFORMAT_BD24); IM_ERROR CreateBitmapFromMemory(PBitmap* hBmp, IMFORMAT_BD format, int nHeight, int nWidth, void* pvPalette, void* pvBits); IM_ERROR CopyBitmap(PBitmap pBmp1, PBitmap pBmp2); IM_ERROR LoadBitmap(cstr pfilename, PBM* pbm); IM_ERROR WriteBitmap(cstr pfilename, PBM pbm); IM_ERROR ConvertBitmapColorDepth(PBitmap pBmp1, IMFORMAT_BD bitdepth); IM_ERROR ConvertBitmap24Bit(PBitmap pBmp1, Byte byChannel=4); IM_ERROR ConvertBitmap32Bit(PBitmap pBmp1, Byte byChannel=4); IM_ERROR ConvertBitmap8SCBit(PBitmap pBmp1, Byte byChannel=0); void DeleteBitmap(PBitmap pBmp1); #endif